C#问题<>

来源:百度知道 编辑:UC知道 时间:2024/05/21 02:49:49
[DataObjectMethod(DataObjectMethodType.Select, true)]
static public List<RoleData> GetRoles()
{
RoleData r = null;
List<RoleData> roleList = new List<RoleData>();//请问这里的<>是什么意思?泛型吗?请大概讲解一下代码的意思
string[] ary = Roles.GetAllRoles();

foreach (string s in ary)
{
r = new RoleData();
r.RoleName = s;

roleList.Add(r);
}

return roleList;
}
谢谢

是的,是范型,定义了个元素 为 RoleData 的list集合 ,名字为 roleList 。
RoleData是你自定义的类;
string[] ary = Roles.GetAllRoles(); //得到的所有角色放入数组

roleList.Add(r);
向其中添加元素 r